package de.mouseless.csv2sql.model;

import java.util.HashMap;
import java.util.Map;

import de.mouseless.csv2sql.common.ApplicationException;

public class Table extends AbstractObject {
   public Table(String name) {
      super(name);
   }
   Map<String, AbstractColumn> columns = new HashMap<String, AbstractColumn>();
   Map<String, AbstractConstraint> constraints = new HashMap<String, AbstractConstraint>();
   
   public void addColumn(AbstractColumn column) {
      if(columns.containsKey(column.getName())) {
         throw new ApplicationException("In Table " + getName() + " a column with name " + column.getName() + " already exists");
      }
      columns.put(column.getName(), column);
   }

   public void addConstraint(AbstractConstraint constraint) {
      constraints.put(constraint.getName(), constraint);
   }
}
